'use strict';
const db = uniCloud.database();
exports.main = async (event, context) => {
  //event为客户端上传的参数
  let result
  let {
    imagePath,
    flag,
    id
  } = event
  //get
  if (flag == 1) {
    result = await db.collection("zhimuta-imageList").get()
  }
  //上传
  if (flag == 2) {
    result = await db.collection("zhimuta-imageList").add({
      imageUrl: imagePath
    })
  }
  if (flag == 3) {
    result = await db.collection("zhimuta-imageList").doc(id).remove()
  }

  //返回数据给客户端
  return result
};